class Solution {
public:
    bool dp[10005];
    bool canJump(vector<int>& nums) {
        if (nums.size() == 1) return 1;
        for (int i = nums.size() - 2; i >= 0; i--)
        {
            if (i + nums[i] >= nums.size() - 1) dp[i] = 1;
            else
            {
                for (int j = i + 1; j <= i + nums[i]; j++)
                {
                    if (dp[j])
                    {
                        dp[i] = 1; break;
                    }
                }
            }
        }
        return dp[0];
    }
};